<template>
  <sn-three-col-space>
    <div slot="spaceContent" class="margin-top">
      <el-row>
        <el-col :span="6" v-for="item in coupons">
          <el-link :underline="false"
                   @click="toDetail">
            <el-image :src="item.couponImg"></el-image>
          </el-link>
          <div align="center">
            <span v-text="item.price"></span>
          </div>
        </el-col>
      </el-row>
    </div>
  </sn-three-col-space>
</template>

<script>
import SnFlexHasThreeElement from "@/components/common/sn/flex/SnFlexAppointElement";

export default {
  name: "Coupon",
  components: {SnFlexHasThreeElement},
  data() {
    return {
      coupons: []
    }
  },
  methods: {
    getDataList() {
      this.dataListLoading = true
      this.$http({
        url: 'web/secKill/currentSecKillCoupon',
        method: 'get',
      }).then(({data}) => {
        let sessions = data.data
        this.coupons = []
        for (let i = 0; i < sessions.length; i++) {
          let {
            couponId,
            couponInfoVO,
            createTime,
            endTime,
            publishCount,
            randomCode,
            seckillId,
            seckillLimit,
            seckillPrice,
            sessionId,
            startTime,
            updateTime,
            vipLimit
          } = sessions[i]

          let coupon = {
            couponImg: couponInfoVO.couponImg,
            price: couponInfoVO.price,
            couponName: couponInfoVO.couponName,
            seckillPrice
          }
          this.coupons.push(coupon)
        }
      })
    },
    toDetail() {
      this.$router.push({
        name: "goodsDetail"
      })
    }
  },
  created() {
    this.getDataList();
  }
}
</script>

<style scoped>

</style>
